Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix stack overflow by enum and cont issue #36163 #38093

Merged
merged 1 commit into from
Dec 5, 2016

Conversation

mikhail-m1
Copy link
Contributor

some paths were skipped while checking for recursion.

I fixed bug reproduces on win64 cargo test. In previous PR #36458 time complexity was exponential in case of linked const values. Now it's linear.

r? @alexcrichton

@alexcrichton
Copy link
Member

Oh I was just helping to debug :)

r? @arielb1

@rust-highfive rust-highfive assigned arielb1 and unassigned alexcrichton Dec 1, 2016
}
}
fn with_item_id_pushed<F>(&mut self, id: ast::NodeId, f: F, span: Span)
where F: Fn(&mut Self)
{
if self.opt_last_id.map_or(false, |last| last == id) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be self.opt_last_id == Some(id), but what is this supposed to be doing?

if self.idstack.iter().any(|&x| x == id) {
if self.detected_recursive_ids.contains(&id) {
Copy link
Contributor

@arielb1 arielb1 Dec 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this could be if let Some(..) = self.detected_recursive_ids.replace(id).

@arielb1
Copy link
Contributor

arielb1 commented Dec 1, 2016

I think you can skip the exponential worst-case by removing visit_expr - the expression will be walked anyway, and visit_path will be reached.

@arielb1
Copy link
Contributor

arielb1 commented Dec 3, 2016

r+ with the "removing visit_expr" change if that works.

… were skipped while checking for recursion.
@mikhail-m1
Copy link
Contributor Author

@arielb1 I've just tested it works, but I thought I tested it before. I also removed RefCell, hope you don't mind.

@arielb1
Copy link
Contributor

arielb1 commented Dec 3, 2016

@bors r+ b8d8ab8

@bors
Copy link
Contributor

bors commented Dec 5, 2016

⌛ Testing commit b8d8ab8 with merge 6bc551a...

bors added a commit that referenced this pull request Dec 5, 2016
fix stack overflow by enum and cont issue #36163

some paths were skipped while checking for recursion.

I fixed bug reproduces on win64 cargo test. In previous PR #36458 time complexity was exponential in case of linked const values. Now it's linear.

r? @alexcrichton
@bors bors merged commit b8d8ab8 into rust-lang:master Dec 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants